<template>
	<view class="container" :style="[{paddingTop:CustomBar+'px'}]">
		<cu-custom bgColor="bg-colorP" :isBack="true">
			<block slot="backText"></block>
			<block slot="content">搜索</block>
		</cu-custom>
		<view class="search-content">
			<view class="header-s">
				<view class="search">
					<image class="icon" src="http://xarkbucket.oss-cn-hangzhou.aliyuncs.com/search.svg"></image>
					<input type="text" confirm-type="搜索" @confirm="search" placeholder='请输入商品名称...' placeholder-class="placeholder"
					 v-model="searchVal"></input>
				</view>
				<view class="search-btn" @click='search'>搜索</view>
			</view>
			<view class="q-content">
				<view class="title">搜索结果</view>
				<view class="q-item" v-for="(item,index) in list_data" :key="index"  @click="nav" :data-url="'/pages/cloudMall/productDetail?id='+item.id">
					<image :src="item.goodsImg" mode=""></image>
					<view class="q-info">
						<view class="">
							{{item.goodsName}}
						</view>
						<view class="">
							<view class="tags">
								<!-- <uni-tag  inverted="false" :text="" size="small" :type="'warning'"></uni-tag> -->
								<view class="tag" v-for="(tag,i) in item.accreds_data" :key="i">
									<image :src="tag.img" mode=""></image>
									<text>{{tag.name}}</text>
								</view>
							</view>
							<view class="">
								<text class="text-price text-colorP">{{item.shopPrice}}</text>
								<text class="text-price">{{item.marketPrice}}</text>
							</view>
						</view>
					</view>
				</view>
				<no-content :showType="'data'" v-if='noContentShow' :tips="'没有匹配得商品，换个词再试试~'"></no-content>
			</view>
		</view>
	</view>
</template>

<script>
	import noContent from '../component/noContent.vue'
	export default {
		components: {
			noContent
		},
		data() {
			return {
				CustomBar: this.CustomBar,
				noContentShow: false,
				historyList: [],
				page: 1,
				searchVal: '',
				newActivityList: [],
				num: '',
				list_data: []
			}
		},
		onShow() {
			
		},
		methods: {
			nav(e){
				var url = e.currentTarget.dataset.url
				if(url){
					uni.navigateTo({
						url: url
					});
				}
			},
			search() {
				var me = this
				me.page = 1
				me.noContentShow = false
				this.$request({
					url: '/ShopGoods/get_shop_goods',
					data: {
						keys: me.searchVal,
						page: me.page
					},
					success: res => {
						if (res.data.status == 1) {
							if (res.data.data.data.length == 0) {
								me.list_data = []
								me.noContentShow = true
								return false
							}
							me.list_data = res.data.data.data
							me.num = res.data.data.totalNum
							me.page++
						}
						uni.hideLoading()
					},
					fail: () => {},
					complete: () => {}
				});
			},
			historySearch(e) {
				var text = e.currentTarget.dataset.text;
				if (text) {
					this.searchVal = text
					this.page = 1
					this.search()
				}
			},
		}
	}
</script>

<style>
	page {
		background: #fff;
	}
</style>
<style scoped>
	.header-s {
		display: flex;
		box-sizing: border-box;
		align-items: center;
		height: 100rpx;
		width: 100%;
		padding: 0 20rpx;
		background: #fff;
		z-index: 999
	}

	.search {
		flex: 1;
		height: 60rpx;
		background: #f3f3f3;
		display: flex;
		align-items: center;
		box-sizing: border-box;
		border-radius: 30rpx;
		padding: 0 20rpx;
		margin-right: 20rpx;
	}

	.placeholder {
		color: #999;
		font-size: 26rpx;
	}

	.search .icon {
		width: 35rpx;
		height: 40rpx;
	}

	.search input {
		flex: 1;
		box-sizing: border-box;
		padding-left: 20rpx;
		font-size: 28rpx;
		color: #999;
	}

	.search-btn {
		font-size: 26rpx;
		color: #3080E8
	}

	.history-info {
		width: 100%;
		height: auto;
		padding: 0 20rpx;
		box-sizing: border-box;
	}

	.title {
		height: 88rpx;
		line-height: 88rpx;
		color: #999999;
		font-size: 30rpx;
	}

	.history-info .his-con {
		display: flex;
		flex-wrap: wrap;
	}

	.history-item {
		padding: 10rpx 15rpx;
		margin-right: 20rpx;
		background: #F4F4F4;
		border-radius: 8rpx;
		color: #333;
		font-size: 26rpx;
		margin-bottom: 10rpx;
	}



	.noLength {
		color: #999;
		font-size: 26rpx;
	}


	.news-alive {
		width: 100%;
		overflow: hidden;
		display: flex;
		padding-bottom: 20rpx;
		box-sizing: border-box;
		position: relative;
		border-bottom: solid 1rpx #f2f2f2;
	}

	.news-alive .head-img {
		width: 150rpx !important;
		height: 150rpx !important;
		border-radius: 8rpx;
		margin-right: 10rpx;
		display: block;
	}

	.news-alive>view:nth-child(2) {
		flex: 1;
	}

	.news-alive>view:nth-child(2)>view:nth-child(1) {
		height: 50rpx;
		display: flex;
	}

	.news-alive>view:nth-child(2)>view:nth-child(1) text {
		font-size: 30rpx;
		color: #333;
		font-weight: bold;
	}

	.news-alive>view:nth-child(2)>view:nth-child(1) image {
		width: 70rpx;
		height: 45rpx;
		margin-left: -10rpx;
	}

	.news-alive>view:nth-child(2)>view:nth-child(2) {
		color: #999;
		font-size: 26rpx;
		margin-top: 10rpx;
	}

	.news-alive>view:nth-child(2)>view:nth-child(2) text {
		color: rgba(246, 96, 132, 1);
	}

	.news-alive>view:nth-child(2)>view:nth-child(3) {
		font-size: 24rpx;
		margin-top: 10rpx;
		color: #666;
	}

	.news-alive>view:nth-child(2)>view:nth-child(3) text {
		color: rgba(246, 96, 132, 1);
	}

	.news-alive .position {
		width: 160rpx !important;
		height: 50rpx;
		line-height: 50rpx;
		position: absolute;
		right: 20rpx;
		top: 50%;
		transform: translateY(-25rpx);
		color: rgba(255, 255, 255, 1);
		background-color: #3080E8;
		border-radius: 30rpx;
		font-size: 24rpx;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.news-alive .position image {
		width: 26rpx;
		height: 26rpx;
		display: inline-block;
		margin-right: 5rpx;
	}
	
	.q-content {
		width: 100%;
		box-sizing: border-box;
		padding: 0 24rpx;
	
	}
	
	.q-content .q-item {
		width: 100%;
		display: flex;
		justify-content: space-between;
		padding: 15rpx 0;
	}
	
	.q-content .q-item image {
		width: 240rpx;
		height: 240rpx;
		margin-right: 20rpx;
		border-radius: 8rpx;
	}
	
	.q-content .q-item .q-info {
		flex: 1;
		height: 240rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
	}
	
	.q-content .q-item .q-info>view:nth-child(1) {
		font-size: 30rpx;
		line-height: 48rpx;
		letter-spacing: 1rpx;
		color: #333333;
		font-weight: bold;
	}
	
	.q-content .q-item .q-info>view:nth-child(2) .tags {
		margin-bottom: 20rpx;
		display: flex;
		align-items: center;
		flex-wrap: wrap;
	}
	
	.q-content .q-item .q-info>view:nth-child(2) .tags .tag {
		display: flex;
		align-items: center;
		justify-content: center;
		padding: 0 10rpx;
		height: 30rpx;
		background-color: rgba(248, 153, 11, .3);
		border-radius: 4rpx;
		box-sizing: border-box;
		margin-right: 10rpx;
		margin-bottom: 10rpx;
	}
	
	.q-content .q-item .q-info>view:nth-child(2) .tags .tag image {
		width: 20rpx;
		height: 20rpx;
		margin-right: 10rpx;
	}
	
	.q-content .q-item .q-info>view:nth-child(2) .tags .tag text {
		letter-spacing: 1rpx;
		color: #b36f0a;
		font-size: 20rpx;
	}
	
	.q-content .q-item .q-info>view:nth-child(2)>view:nth-child(2) {
		display: flex;
		align-items: center;
	}
	
	.q-content .q-item .q-info>view:nth-child(2)>view:nth-child(2)>text:nth-child(1) {
		font-weight: bold;
		font-size: 30rpx;
		letter-spacing: 1rpx;
	}
	
	.q-content .q-item .q-info>view:nth-child(2)>view:nth-child(2)>text:nth-child(2) {
		font-size: 24rpx;
		text-decoration: line-through;
		letter-spacing: 1rpx;
		color: #999;
		margin-left: 20rpx;
	}
</style>
